package com.bike.bikeserver.controller.frontend;

import com.bike.bikeserver.common.annotation.OperationLog;
import com.bike.bikeserver.common.core.domain.CommonResult;
import com.bike.bikeserver.service.IRewardsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @version 1.0
 * @Author ZZX
 * @Date 2023/7/11 15:24
 */
@RestController
@RequestMapping("front/rewards")
public class RewardsController
{
    @Autowired
    IRewardsService rewardsService;

    /**
     * 获取所有奖券信息
     * @return
     */
    @GetMapping("getRewardsList")
    public CommonResult getRewardsList()
    {
        return rewardsService.getRewardsList();
    }

    /**
     * 获取所有奖券信息[特供版]
     * @return
     */
    @GetMapping("getRewardsForHistory")
    public CommonResult getRewardsForHistory()
    {
        return rewardsService.getRewardsForHistory();
    }

    /**
     * 为用户兑换奖券
     * @param params
     * @return
     */
    @OperationLog(value = "为用户兑换奖券:rewards")
    @PostMapping("exchangeRewardsByNickName")
    public CommonResult exchangeRewardsByNickName(@RequestBody Map<String, Object> params)
    {
        String nickName = (String) params.get("nickName");
        Integer rewardsId = (Integer) params.get("rewardsId");
        return rewardsService.exchangeRewardsByNickName(nickName,rewardsId);
    }
}
